{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/lzq/miniconda3/lib/python3.10/site-packages/tqdm/auto.py:22: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
      "  from .autonotebook import tqdm as notebook_tqdm\n",
      "INFO:root:**************************** start to evaluate *******************************\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "load pretrained weight from /home/lzq/work/Vision-Transformer-ViT/./output/mvit/2023-03-13-6.pt.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Iteration: 100%|██████████| 313/313 [01:19<00:00,  3.95it/s]\n",
      "INFO:root:Accuracy: 0.985300\n"
     ]
    }
   ],
   "source": [
    "import json\n",
    "from argparse import Namespace\n",
    "from data import get_cifar10_dataloader\n",
    "from mmsa import build_mvit, get_mask_val_from_masks\n",
    "from train import eval_model\n",
    "\n",
    "\n",
    "train_loader = get_cifar10_dataloader()\n",
    "test_loader = get_cifar10_dataloader(train=False)\n",
    "\n",
    "args = Namespace(**json.load(open(\"/home/lzq/work/Vision-Transformer-ViT/ViT-B_16-224.json\", 'r')))\n",
    "\n",
    "# train_mvit(args, train_loader, freeze_w=True)\n",
    "\n",
    "args.cifar10_vit = './output/mvit/2023-03-13-6.pt'\n",
    "mvit = build_mvit(args)\n",
    "\n",
    "eval_model(mvit, test_loader, 'cuda:0')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "load pretrained weight from /home/lzq/work/Vision-Transformer-ViT/./output/0.9853000044822693.pt.\n"
     ]
    }
   ],
   "source": [
    "args.cifar10_vit = './output/0.9853000044822693.pt'\n",
    "mvit_ori = build_mvit(args)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.9"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
